package com.qzdsoft.erpcloud.service.basic.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.qzdsoft.erpcloud.domain.basic.BillDeocdeParam;
import com.qzdsoft.erpcloud.mapper.basic.BillDeocdeParamMapper;
import com.qzdsoft.erpcloud.service.basic.BillDeocdeParamService;
import com.qzdsoft.erpcloud.vo.query.basic.BillDeocdeParamInfo;
import com.qzdsoft.vo.LayTableResponse;
import com.qzdsoft.vo.Response;
import com.qzdsoft.vo.ResultEnum;

/**
 * Created by Admin
 */
@Service
public class BasicBillDeocdeParamServiceImpl implements BillDeocdeParamService {

    @Autowired
    private BillDeocdeParamMapper basicBillDeocdeParamMapper;

    @Override
    public BillDeocdeParam selectById(Integer id) {
        return basicBillDeocdeParamMapper.selectByPrimaryKey(id);
    }

    @Override
    public Response<String> saveOrUpd(BillDeocdeParam basicBillDeocdeParam) {
        if(null != basicBillDeocdeParam.getId()){
            basicBillDeocdeParamMapper.updateByPrimaryKey(basicBillDeocdeParam);
        } else {
            basicBillDeocdeParamMapper.insert(basicBillDeocdeParam);
        }
        return new Response<String>(ResultEnum.SUCCESS);
    }

    @Override
    public Response<String> del(Integer id) {
        basicBillDeocdeParamMapper.deleteByPrimaryKey(id);
        return new Response<String>(ResultEnum.SUCCESS);
    }

    @Override
    public LayTableResponse<BillDeocdeParamInfo> selectData(Integer typeId, Integer companyId, Integer decodeMethod, Integer prifixFirst, Integer prifixSecond, Integer prifixThree, Integer start, Integer pageSize) {
        PageHelper.startPage(start, pageSize);
        List<BillDeocdeParamInfo> list = basicBillDeocdeParamMapper.selectData(typeId, companyId, decodeMethod, prifixFirst, prifixSecond, prifixThree, start, pageSize);
        return new LayTableResponse<BillDeocdeParamInfo>(list);
    }
}
